#include <stdio.h>
#include "process.h"

void download(callback_t cb)
{
    int testcnt = 100;
    int target = TARGET_SIZE;
    int total = 0;
    while(total <= target)
    {
        usleep(STIME);
        total += DSIZE;
        double rate = total*100/target;
        if(rate > 50.0 && testcnt)
        {
            total = target / 2;
            testcnt--;
        }
        cb(rate);
    }
    printf("\n");
}

int main()
{
    download(process);
    return 0;
}
